// ErrorBoundaryTestMainApp.tsx
import React from 'react';
import { View, Text, Button } from 'react-native';

export default function ErrorBoundaryTestMainApp() {
  const [crash, setCrash] = React.useState(false);

  if (crash) {
    // 💥 模拟渲染阶段出错
    throw new Error('渲染错误：模拟组件渲染异常！');
  }

  return (
    <View style={{ padding: 20 }}>
      <Text style={{ marginBottom: 10 }}>
        点击下面按钮模拟渲染错误（ErrorBoundary 会捕获到）
      </Text>
      <Button title="触发渲染错误" onPress={() => setCrash(true)} />
    </View>
  );
}
